package com.example.framework;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.Select;

public abstract class BaseHelper {
	
	protected ApplicationManager manager;
	protected WebDriver driver;
	
	public BaseHelper (ApplicationManager manager){
		this.manager = manager;
		this.driver = manager.driver;
	}

	protected void type(By locator, String text) {
		driver.findElement(locator).clear();
		driver.findElement(locator).sendKeys(text);
	}

	protected void selectByText(By locator, String text) {
		if (text == null || text.equals("")) {
			new Select(driver.findElement(locator))
			.selectByIndex(0);
		}
		else {
			new Select(driver.findElement(locator))
			.selectByVisibleText(text);
		}
	}

	protected void click(By locator) {
		driver.findElement(locator).click();
	}

}
